package com.fourth.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;

/**
 * @author 悍城
 * @date 2023/02/27 15:01
 * @project factory
 */
@Data
@ApiModel(value = "新增或更新数据源类")
public class   AddOrUpdateDatabaseDto {

    /**
     * id
     */
    @ApiModelProperty(value = "数据源id")
    @Min(value = 0, message = "只能输入非零的正整数")
    private Integer id;

    /**
     * 数据源名称
     */
    @NotBlank(message = "数据源名称不能为空")
    @Length(min = 1, max = 200, message = "数据源名称长度应在{min}~{max}个字符")
    @Pattern(regexp = "^[A-Za-z0-9\u4e00-\u9fa5_]+$", message = "数据源名称仅支持中英文大小写、数字、下划线")
    @ApiModelProperty(value = "数据源名称", required = true)
    private String name;

    /**
     * 数据源描述
     */
    @Length(max = 200, message = "数据源描述长度不应大于{max}个字符")
    @ApiModelProperty(value = "数据源描述")
    private String description;

    /**
     * 数据源url
     */
    @NotBlank(message = "数据源url不能为空")
    @Length(max = 100, message = "数据源url长度不应大于{max}个字符")
    @ApiModelProperty(value = "数据源url", required = true)
    private String jdbcUrl;

    /**
     * 驱动类名
     */
    @NotBlank(message = "驱动类名不能为空")
    @ApiModelProperty(value = "驱动类名", required = true)
    private String driverClass;

    /**
     * 用户名
     */
    @ApiModelProperty(value = "用户名")
    private String userName;

    /**
     * 密码
     */
    @ApiModelProperty(value = "密码")
    private String password;

    /**
     * 数据库类型，默认Mysql
     */
    @ApiModelProperty(value = "数据库类型，默认Mysql", required = true)
    private String type;

}
